<?php

namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Topic;
use Illuminate\Http\Request;

class CategoriesController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth',[
           'except' => ['show'],
        ]);
    }
    public function show(Category $category , Request $request)
    {
        $topics = Topic::withOrder($request->order)->where('category_id',$category->id)->paginate(15);
        return view('topics.index',compact('topics','category'));
    }
}
